#include "project.h"
#include<ctime>

int main(int argc, char* argv[])
{
    TimeIntergratorFactory T;
    const bool _AB1_registered = T.RegisterTimeIntergrator({"AB1", 1}, CreateAB1);
    const bool _AB2_registered = T.RegisterTimeIntergrator({"AB2", 2}, CreateAB2);
    const bool _AB3_registered = T.RegisterTimeIntergrator({"AB3", 3}, CreateAB3);
    const bool _AB4_registered = T.RegisterTimeIntergrator({"AB4", 4}, CreateAB4);
    const bool _AM2_registered = T.RegisterTimeIntergrator({"AM2", 2}, CreateAM2);
    const bool _AM3_registered = T.RegisterTimeIntergrator({"AM3", 3}, CreateAM3);
    const bool _AM4_registered = T.RegisterTimeIntergrator({"AM4", 4}, CreateAM4);
    const bool _AM5_registered = T.RegisterTimeIntergrator({"AM5", 5}, CreateAM5);
    const bool _BDF1_registered = T.RegisterTimeIntergrator({"BDF1", 1}, CreateBDF1);
    const bool _BDF2_registered = T.RegisterTimeIntergrator({"BDF2", 2}, CreateBDF2);
    const bool _BDF3_registered = T.RegisterTimeIntergrator({"BDF3", 3}, CreateBDF3);
    const bool _BDF4_registered = T.RegisterTimeIntergrator({"BDF4", 4}, CreateBDF4);
    const bool _RK4_registered = T.RegisterTimeIntergrator({"RK4", 4}, CreateRK4);
    std::pair<std::string, int> method_p;
    int testcase;//choose which case you want to test
    std::cin >> method_p.first >> method_p.second >> testcase;
    TimeIntergrator *t = T.CreateTimeIntergrator(method_p);
    std::vector<double> init1 = {0.994, 0, 0, 0, -2.0015851063790825224, 0};
    std::vector<double> init2 = {0.87978, 0, 0, 0, -0.3797, 0};
    double T1 = 17.06521656015796;
    double T2 = 19.14045706162071;
    if(testcase == 1)
    	t->solver(init1, T1);
    else
    	t->solver(init2, T2);
    std::cout << "x = u(:,1);" << std::endl;
    std::cout << "y = u(:,2);" << std::endl;
    std::cout << "plot(x, y)" << std::endl;

    // //compute CPU time
    // clock_t startTime, endTime, time;
    // if(testcase == 1)
    // {
    // 	time = 0;
    // 	startTime = clock();
    // 	t->solver(init1, T1);
    // 	endTime = clock();
    // 	time = (double)(endTime - startTime)*1000/(double)CLOCKS_PER_SEC;
    // 	std::cout << "The CPU time is " << time << "ms" << std::endl;
    // }
    // else
    // {
    // 	time = 0;
    // 	startTime = clock();
    // 	t->solver(init2, T2);
    // 	endTime = clock();
    // 	time = (double)(endTime - startTime)*1000/(double)CLOCKS_PER_SEC;
    // 	std::cout << "The CPU time is " << time << "s" << std::endl;
    // }
    return 0;
};
